﻿using DevExpress.Data;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid;
using DXApplicationTangche.UC.报表.service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.报表
{
    public partial class Form最新库存 : DevExpress.XtraEditors.XtraForm
    {
        public Form最新库存()
        {
            InitializeComponent();
            this.dataRefresh库存();
            this.dataRefresh门店调拨工厂();
            this.dataRefresh实时库存();
        }

        public void dataRefresh实时库存()
        {
            //  查询库存
            this.gridControl实时库存.DataSource = 报表Service.get实时库存();
            this.gridView实时库存.RefreshData();
            this.gridView实时库存.GroupSummary.Add(new GridGroupSummaryItem(SummaryItemType.Count, "barcode", null, "(数量合计 = {0})"));
        }
        public void dataRefresh库存()
        {
            //  查询库存
            this.gridControl库存.DataSource = 抖音报表service.getStock();
            this.gridView库存.RefreshData();
        }
        public void dataRefresh门店调拨工厂()
        {
            // 查询门店调拨工厂调拨单及明细
            this.gridControl门店调拨工厂.DataSource = 报表Service.get门店调拨工厂列表();
            this.gridView门店调拨工厂.RefreshData();
        }

        private void simpleButton刷新_Click(object sender, EventArgs e)
        {
            this.dataRefresh库存();
        }

        private void simpleButton刷新返工厂调拨单_Click(object sender, EventArgs e)
        {
            this.dataRefresh门店调拨工厂();
        }

        private void gridView门店调拨工厂_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            try
            {
                if (e.Column.Name.Equals("gridColumnstylesizecd"))
                {
                    if (!String.IsNullOrWhiteSpace(e.DisplayText))
                    {
                        try { e.DisplayText = e.DisplayText.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                    }
                }
            }
            catch { }
        }

        private void simpleButton刷新实时库存_Click(object sender, EventArgs e)
        {
            this.dataRefresh实时库存();
        }

        private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            try
            {
                if (e.Column.Name.Equals("gridColumn尺码"))
                {
                    if (!String.IsNullOrWhiteSpace(e.DisplayText))
                    {
                        try { e.DisplayText = e.DisplayText.Replace("IGS_GROUP_SIZE-", "").Replace("EGS_GROUP_SIZE-", ""); } catch { }
                    }
                }
            }
            catch { }
        }
    }
}